package com.vsoontech.demo.component;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import com.vsoontech.demo.component.databinding.ActivityMainBinding;
import com.vsoontech.demo.componentlib.ServiceFactory;

public class MainActivity extends AppCompatActivity {

    ActivityMainBinding mBinding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        mBinding.btnLogin.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // 跳转登录页面
                ServiceFactory.getInstance().getLoginService().startLogin(v.getContext());
                // 添加登录用户中心Fragment到容器中
                ServiceFactory.getInstance().getLoginService()
                    .getUserFragment(MainActivity.this.getSupportFragmentManager(), mBinding.flContaint.getId(), null);
            }
        });
        mBinding.btnMine.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // 跳转Mine页面
                ServiceFactory.getInstance().getMineService().startMine(v.getContext());
            }
        });
    }
}
